package service

import (
	"encoding/json"
	"errors"
	"context"
	"net/http"
	"strconv"
	"fmt"
)

func GetUserRequest(ctx context.Context, req *http.Request, r interface{})(error){
	userRequest := r.(UserRequest)
	fmt.Println("服务端地址:", req.URL.Path)
	req.URL.Path += "/user/" + strconv.Itoa(userRequest.Uid)
	return nil
}

func PutUserResponse(ctx context.Context, res *http.Response) (response interface{}, err error){
	if  res.StatusCode > 400 {
		return nil, errors.New("not data")
	}

	var userRespones UserResponse
	err = json.NewDecoder(res.Body).Decode(&userRespones)
	if err != nil{
		return nil, err
	}

	return userRespones, nil

}